﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACP.DTO;

namespace ACP.Data
{
    public class ExamTypeRepository
    {

        public static examtype  GetExamType(int id)
        {
            Repository<examtype> userRepository = new Repository<examtype>();
            examtype examTypeEntity;
            try
            {
                examTypeEntity = userRepository.First(x => x.examtypeid == id);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                userRepository.Dispose();
            }
            return examTypeEntity;
        }

        /// <summary>
        /// Get Exam types(i.e. Sample or 25 Questions or 60 Questions)
        /// </summary>
        /// <returns></returns>
        public static List<examtype> getExamTypeList()
        {
            Repository<examtype> examTypeRepository = new Repository<examtype>();
            List<examtype> lstSupporTypes;
            try
            {
                lstSupporTypes = examTypeRepository.AsQueryable().OrderBy(s => s.examtypeid).ToList();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
              examTypeRepository.Dispose();
            }
            return lstSupporTypes;
        }

        /// <summary>
        /// Get Examination types from exam table(i.e. Acpexam, PMPexam)
        /// </summary>
        /// <returns></returns>
        public static List<exam> GetExaminationsTypes()
        {
            Repository<exam> examRepository = new Repository<exam>();
            List<exam> lstExamTypes;
            try
            {
                lstExamTypes = examRepository.AsQueryable().Where(q => q.status == true).OrderBy(s => s.examname).ToList();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                examRepository.Dispose();
            }
            return lstExamTypes;
        }
    }

   
    
}
